package helper
{
	import com.adobe.serialization.json.JSON;
	import flash.net.URLLoader;
	
	import flash.net.URLRequest;
	import flash.net.URLVariables;

	public class Services 
	{
		
		private const RESOURCE_URL:String ="http://www.tietkiemphudong.vn/wp-content/games/gameserver/index.php/resource/getResource";
		private const TASK_URL:String="http://www.tietkiemphudong.vn/wp-content/games/gameserver/index.php/task/getTasklist";
		private const DO_TASK_URL:String ="http://www.tietkiemphudong.vn/wp-content/games/gameserver/index.php/task/doTask/";
		private const GET_QUESTION_URL:String ="http://www.tietkiemphudong.vn/wp-content/games/gameserver/index.php/task/getQuestion";
		private const DO_QUESTION_URL:String="http://www.tietkiemphudong.vn/wp-content/games/gameserver/index.php/task/doQuestion/";
		private const GET_MISSION_URL:String ="http://www.tietkiemphudong.vn/wp-content/games/gameserver/index.php/mission/getMission/";
		private const DO_MISSION_URL:String="http://www.tietkiemphudong.vn/wp-content/games/gameserver/index.php/mission/doMission/";
		private const GET_MISSION_LIST_URL:String="http://www.tietkiemphudong.vn/wp-content/games/gameserver/index.php/mission/getMissionList";
		private const GET_TOP_URL:String="http://www.tietkiemphudong.vn/wp-content/games/gameserver/index.php/show/getTop/";
		private const GET_LIMIT_TIME_URL:String = "http://www.tietkiemphudong.vn/wp-content/games/gameserver/index.php/show/getLimitTime";
		private const GET_REWARD_URL:String = "http://www.tietkiemphudong.vn/wp-content/games/gameserver/index.php/resource/getReward";
		private const GET_DEPOSIT_URL:String = "http://www.tietkiemphudong.vn/wp-content/games/gameserver/index.php/resource/setDeposit";
		private const PING_URL:String = "http://www.tietkiemphudong.vn/wp-content/games/gameserver/index.php/resource/ping";
		
		public static var instance:Services;
		public function Services()
		{
			if(!instance){
				instance = this;
			}
			doTaskRequest(3);
		
		}
		public static function getInstance():Services{
			if(!instance){
				instance = new Services();
			}
			return instance;
		}
		public function getResourceRequest():URLRequest{
			return new URLRequest(RESOURCE_URL);
		}
		public function getTaskListRequest():URLRequest{
			return new URLRequest(TASK_URL);
		}
		public function doTaskRequest(taskId:Number):URLRequest{
			return new URLRequest(DO_TASK_URL + taskId);
			
		}
		public function getQuestionRequest():URLRequest{
			return new URLRequest(GET_QUESTION_URL);
		}
		public function doQuestionRequest(questionId:Number,answer:Number):URLRequest{
			return new URLRequest(DO_QUESTION_URL+questionId+"/"+answer);
		}
		public function getMissionRequest(missionId:Number):URLRequest{
			return new URLRequest(GET_MISSION_URL + missionId);
		}
		public function doMissionRequest(missionId:Number):URLRequest{
			return new URLRequest(DO_MISSION_URL + missionId);
		}
		public function getMissionListRequest():URLRequest{
			return new URLRequest(GET_MISSION_LIST_URL);
		}
		public function getTopRequest(week:String):URLRequest{
			return new URLRequest(GET_TOP_URL + week);
		}
		public function getLimitTimeRequest():URLRequest{
			return new URLRequest(GET_LIMIT_TIME_URL);
		}
		public function getRewardRequest():URLRequest {
			return new URLRequest(GET_REWARD_URL);
		}
		public function getDepositRequest():URLRequest {
			return new URLRequest(GET_DEPOSIT_URL);
		}
		public function pingRequest():URLRequest {
			return new URLRequest(PING_URL);
		}
	}
}